<?php
/**
 * @author zhaofei
 * @package 商店
 * @createtime 20self::MODEL_BOTH4-self::MODEL_BOTHself::MODEL_BOTH-25
 * @updatetime 20self::MODEL_BOTH4-self::MODEL_BOTHself::MODEL_BOTH-25
 * @ps:
 */
namespace System\Model;
use Think\Model;
class StoreModel extends Model{

	protected $_validate =array(
		array('name','require','店铺名不能为空',self::MODEL_BOTH),
		array('name','','帐号名称已经存在！',0,'unique',self::MODEL_INSERT), // 在新增的时候验证name字段是否唯一
		array('provice','require','请选择省份',self::MODEL_BOTH),
		array('city','require','请选择城市',self::MODEL_BOTH),
		array('area','require','请选择地区',self::MODEL_BOTH),
	);
	
	protected $_auto = array (
		array('status',1,self::MODEL_INSERT),
		array('sort',0,self::MODEL_INSERT),
		array('create_time','time',self::MODEL_INSERT,'function'),
		array('ct_by_id','getId',self::MODEL_INSERT,'callback'),
		array('update_time','time',self::MODEL_BOTH,'function'),
		array('up_by_id','getId',self::MODEL_BOTH,'callback'),
	);

	public function getId(){
		return session('id');
	}

	public function getStoreBaseById($id){
		$rs = D('Store')->where(array('id'=>$id))->find();
		if($rs){
			return $rs['provice'].' '.$rs['city'].' '.$rs['area']."《<b>".$rs['name']."</b>》";
		}else{
			return '无此终端';
		}
	}
}
?>